<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:nyext="urn:noury-extensions" exclude-result-prefixes="xsl nyext msxsl">
  <xsl:output method="text" encoding="UTF-8"/>

  <xsl:param name="package" />
  <xsl:param name="outdir" />
  <xsl:param name="name" />
  <xsl:param name="domainName" />
  <xsl:variable name="domain" select="/manifest/types/domain[@name=$domainName]" />
  <xsl:variable name="domainProps" select="$domain/interface/property[@type=/manifest/types/domain/@name]" />
  <xsl:variable name="properties" select="$domain/interface/property[not(@type=/manifest/types/domain/@name)]" />

  <xsl:include href="functions.xslt" />


  <!--Template pour récupérer le nom complet du controle-->
  <xsl:template name="get-name">
    <xsl:variable name="property_type" select="@type"/>
    <xsl:variable name="property_name" select="@name"/>
    <xsl:variable name="enum_type" select="/manifest/types/enum[@name=$property_type]" />
    <xsl:value-of select="$property_name" />
    <xsl:text>Editor</xsl:text>
<!--
    <xsl:choose>
      <xsl:when test="$property_type='bool'">
        <xsl:text>ComboBox</xsl:text>
      </xsl:when>
      <xsl:when test="$enum_type">
        <xsl:text>DropDownList</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>TextBox</xsl:text>
      </xsl:otherwise>
    </xsl:choose>
-->
  </xsl:template>

  <!--Template pour récupérer le type du controle-->
  <xsl:template name="get-type">
    <xsl:variable name="property_type" select="@type"/>
    <xsl:variable name="enum_type" select="/manifest/types/enum[@name=$property_type]" />
    <xsl:choose>
      <xsl:when test="$property_type='bool'">
        <xsl:text>CheckBox </xsl:text>
      </xsl:when>
      <xsl:when test="$enum_type">
        <xsl:text>ComboBox </xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>TextBox </xsl:text>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!--Template pour récupérer le label du controle-->
  <xsl:template name="get-label">
    <xsl:value-of select="@name" />
    <xsl:text>Label</xsl:text>
  </xsl:template>

  <!--Template pour déclarer les variables des controles-->
  <xsl:template match="property" mode="declare">
    <xsl:text>private System.Windows.Forms.Label </xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text>;
    private System.Windows.Forms.</xsl:text>
    <xsl:call-template name="get-type" />
    <xsl:call-template name="get-name" />
    <xsl:text>;
    </xsl:text>
  </xsl:template>

  <!--Template pour créer les instances des controles-->
  <xsl:template match="property" mode="create-instance">
    <xsl:text>this.</xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text> = new System.Windows.Forms.Label();
    </xsl:text>
    <xsl:text>this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text> = new System.Windows.Forms.</xsl:text>
    <xsl:call-template name="get-type" />
    <xsl:text>();
    </xsl:text>
  </xsl:template>

  <!--Template pour initialiser les parametres des controles-->
  <xsl:template match="property" mode="initialize">
    <xsl:variable name="property_type" select="@type"/>
    <xsl:variable name="enum_type" select="/manifest/types/enum[@name=$property_type]" />
    <xsl:choose>
      <xsl:when test="@type='bool'">
        <xsl:call-template name="Label" />
        <xsl:call-template name="CheckBox" />
      </xsl:when>
      <xsl:when test="$enum_type">
        <xsl:call-template name="Label" />
        <xsl:call-template name="ComboBox" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="Label" />
        <xsl:call-template name="TextBox" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!--Template pour initialiser une TextBox-->
  <xsl:template name="TextBox">
    <xsl:text>//
    // </xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>
    //
    resources.ApplyResources(this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>, "</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>");
    this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>.DataBindings.Add(new System.Windows.Forms.Binding("Text", this._BindingSource, "</xsl:text>
    <xsl:value-of select="@field" />
    <xsl:text>", true));
    this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>.Name = "</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>";
    </xsl:text>
  </xsl:template>

  <!--Template pour initialiser une ComboBox-->
  <xsl:template name="ComboBox">
    <xsl:text>//
    // </xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>
    //
    resources.ApplyResources(this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>, "</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>");
    this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>.DataBindings.Add(new System.Windows.Forms.Binding("SelectedItem", this._BindingSource, "</xsl:text>
    <xsl:value-of select="@field" />
    <xsl:text>", true));
    this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>.FormattingEnabled = true;
    this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>.Name = "</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>";
    </xsl:text>
  </xsl:template>

  <!--Template pour initialiser une CheckBox-->
  <xsl:template name="CheckBox">
    <xsl:text>//
    // </xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>
    //
        resources.ApplyResources(this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>, "</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>");
    this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this._BindingSource, "</xsl:text>
    <xsl:value-of select="@field" />
    <xsl:text>", true));
    this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>.Name = "</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>";
    </xsl:text>
  </xsl:template>

  <!--Template pour initialiser un Label-->
  <xsl:template name="Label">
    <xsl:text>//
    // </xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text>
    //
    resources.ApplyResources(this.</xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text>, "</xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text>");
    this.</xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text>.Name = "</xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text>";
    </xsl:text>
  </xsl:template>

  <!--Template pour initialiser les parametres des controles-->
  <xsl:template match="property" mode="create-table">
    <xsl:text>this.TableLayoutPanel.Controls.Add(this.</xsl:text>
    <xsl:call-template name="get-label" />
    <xsl:text>, 0, </xsl:text>
    <xsl:value-of select="position()"/>
    <xsl:text>);
    this.TableLayoutPanel.Controls.Add(this.</xsl:text>
    <xsl:call-template name="get-name" />
    <xsl:text>, 1, </xsl:text>
    <xsl:value-of select="position()"/>
    <xsl:text>);
    this.TableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.AutoSize));
    </xsl:text>
  </xsl:template>

  <!--Template pour calculer la hauteur du form control-->
  <xsl:template name="get-hsize">
    <xsl:variable name="NbCbx" select="count($properties[@type='bool'])" />
    <xsl:variable name="NbOther" select="count($properties) - $NbCbx" />
    <xsl:value-of select="($NbCbx*20)+($NbOther*27)"/>
  </xsl:template>

  <xsl:template name="generate-user-file">
    <xsl:text>// $Id$
/*! \file
 * \brief Definition of </xsl:text>
      <xsl:value-of select="$package" />
      <xsl:text>.</xsl:text>
      <xsl:value-of select="$name" />
      <xsl:text>.
 *
 * \author $Author$
 * \date $Date$
 * \version $Revision$
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Salamanca.DataAccess.Collections;
using Salamanca.DataAccess;

namespace </xsl:text>
      <xsl:value-of select="$package" />
      <xsl:text>
{



    ///////////////////////////////////////////////////////////////////////////
    ///
    /// &lt;summary /&gt;
    ///
    ///////////////////////////////////////////////////////////////////////////

    public partial class </xsl:text>
      <xsl:value-of select="$name" />
      <xsl:text>:
        UserControl,
        DomainModel.I</xsl:text>
        <xsl:value-of select="$domainName" />
        <xsl:text>Container
    {
        /// &lt;summary /&gt;
        public </xsl:text>
      <xsl:value-of select="$name" />
      <xsl:text>()
        {
            InitializeComponent();
        }

        /// &lt;summary /&gt;
        public DomainModel.</xsl:text>
        <xsl:value-of select="$domainName" />
        <xsl:text> </xsl:text>
        <xsl:value-of select="$domainName" />
        <xsl:text>
        {
          get
          {
                return (DomainModel.</xsl:text>
                <xsl:value-of select="$domainName" />
                <xsl:text>)_BindingSource.DataSource;
          }
          set
          {
                _BindingSource.DataSource = value;
          }
        }

    }
}
</xsl:text>
    </xsl:template>

    <xsl:template name="generate-designer-file">
      <xsl:variable name="src">
        <xsl:text>// $Id$
using System;

namespace </xsl:text>
        <xsl:value-of select="$package" />
        <xsl:text>
{

    /// &lt;summary /&gt;
    partial class </xsl:text>
        <xsl:value-of select="$name" />
        <xsl:text>
    {
        /// &lt;summary&gt;
        /// Variable nécessaire au concepteur.
        /// &lt;/summary&gt;
        private System.ComponentModel.IContainer components=null;

        /// &lt;summary&gt;
        /// Nettoyage des ressources utilisées.
        /// &lt;/summary&gt;
        /// &lt;param name="disposing"&gt;true si les ressources managées doivent être supprimées ; sinon, false.&lt;/param&gt;
        protected override void Dispose(bool disposing)
        {
            if (disposing&amp;&amp;(components!=null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Code généré par le Concepteur de composants

        /// &lt;summary&gt;
        /// Méthode requise pour la prise en charge du concepteur - ne modifiez pas 
        /// le contenu de cette méthode avec l'éditeur de code.
        /// &lt;/summary&gt;
        private void InitializeComponent()
        {
            this.components=new System.ComponentModel.Container();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DomainModel.</xsl:text>
            <xsl:value-of select="$domainName" />
            <xsl:text>));
            </xsl:text>
        <xsl:apply-templates select="$properties" mode="create-instance"/>
        <xsl:text>
            this._BindingSource = new System.Windows.Forms.BindingSource(this.components);
            this._ErrorProvider = new System.Windows.Forms.ErrorProvider(this.components);
            this.TableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
            this.TableLayoutPanel.SuspendLayout();
            this.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this._BindingSource)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this._ErrorProvider)).BeginInit();

            //
            // _BindingSource
            //
            this._BindingSource.DataSource = typeof(DomainModel.</xsl:text>
            <xsl:value-of select="$domainName" />
           <xsl:text>);
            //
            // _ErrorProvider
            //
            this._ErrorProvider.ContainerControl = this;
            this._ErrorProvider.DataSource = this._BindingSource;
            </xsl:text>
            <xsl:apply-templates select="$properties" mode="initialize"/>
            <xsl:text>
            //
            // TableLayoutPanel
            //
            resources.ApplyResources(this.TableLayoutPanel, "TableLayoutPanel");
            this.TableLayoutPanel.Name = "TableLayoutPanel";
            this._ErrorProvider.SetIconAlignment(this.TableLayoutPanel, System.Windows.Forms.ErrorIconAlignment.TopLeft);
            <!--this.TableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 29.41176F));
            this.TableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 70.58823F));-->
            </xsl:text>
            <xsl:apply-templates select="$properties" mode="create-table"/>
            <xsl:text>
            //
            // </xsl:text>
            <xsl:value-of select="$name" />
            <xsl:text>
            //
            resources.ApplyResources(this, "$this");
            this.AutoScaleMode=System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.TableLayoutPanel);
            this._ErrorProvider.SetIconAlignment(this, System.Windows.Forms.ErrorIconAlignment.TopLeft);
            this.Name = "</xsl:text>
            <xsl:value-of select="$name" />
            <xsl:text>";
            ((System.ComponentModel.ISupportInitialize)(this._BindingSource)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this._ErrorProvider)).EndInit();
            this.TableLayoutPanel.ResumeLayout(false);
            this.TableLayoutPanel.PerformLayout();
            this.ResumeLayout(false);
        }

        #endregion

        </xsl:text>
        <xsl:apply-templates select="$properties" mode="declare"/>
        <xsl:text>private System.Windows.Forms.TableLayoutPanel TableLayoutPanel;
        private System.Windows.Forms.BindingSource _BindingSource;
        private System.Windows.Forms.ErrorProvider _ErrorProvider;
    }
}
</xsl:text>
      </xsl:variable>
      <xsl:value-of select="nyext:generateFile($src, nyext:combinePath($outdir, concat(nyext:getDesignerFileName($name), '.cs')))" />
    </xsl:template>

    <xsl:template name="generate-res-file">
      <xsl:variable name="src">
        <root>
          <xsl:comment>
            <xsl:text>
    Microsoft ResX Schema 
    
    Version 2.0
    
    The primary goals of this format is to allow a simple XML format 
    that is mostly human readable. The generation and parsing of the 
    various data types are done through the TypeConverter classes 
    associated with the data types.
    
    Example:
    
    ... ado.net/XML headers &amp; schema ...
    &lt;resheader name="resmimetype"&gt;text/microsoft-resx&lt;/resheader&gt;
    &lt;resheader name="version"&gt;2.0&lt;/resheader&gt;
    &lt;resheader name="reader"&gt;System.Resources.ResXResourceReader, System.Windows.Forms, ...&lt;/resheader&gt;
    &lt;resheader name="writer"&gt;System.Resources.ResXResourceWriter, System.Windows.Forms, ...&lt;/resheader&gt;
    &lt;data name="Name1"&gt;&lt;value&gt;this is my long string&lt;/value&gt;&lt;comment&gt;this is a comment&lt;/comment&gt;&lt;/data&gt;
    &lt;data name="Color1" type="System.Drawing.Color, System.Drawing"&gt;Blue&lt;/data&gt;
    &lt;data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"&gt;
        &lt;value&gt;[base64 mime encoded serialized .NET Framework object]&lt;/value&gt;
    &lt;/data&gt;
    &lt;data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"&gt;
        &lt;value&gt;[base64 mime encoded string representing a byte array form of the .NET Framework object]&lt;/value&gt;
        &lt;comment&gt;This is a comment&lt;/comment&gt;
    &lt;/data&gt;
                
    There are any number of "resheader" rows that contain simple 
    name/value pairs.
    
    Each data row contains a name, and value. The row also contains a 
    type or mimetype. Type corresponds to a .NET class that support 
    text/value conversion through the TypeConverter architecture. 
    Classes that don't support this are serialized and stored with the 
    mimetype set.
    
    The mimetype is used for serialized objects, and tells the 
    ResXResourceReader how to depersist the object. This is currently not 
    extensible. For a given mimetype the value must be set accordingly:
    
    Note - application/x-microsoft.net.object.binary.base64 is the format 
    that the ResXResourceWriter will generate, however the reader can 
    read any of the formats listed below.
    
    mimetype: application/x-microsoft.net.object.binary.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
            : and then encoded with base64 encoding.
    
    mimetype: application/x-microsoft.net.object.soap.base64
    value   : The object must be serialized with 
            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
            : and then encoded with base64 encoding.

    mimetype: application/x-microsoft.net.object.bytearray.base64
    value   : The object must be serialized into a byte array 
            : using a System.ComponentModel.TypeConverter
            : and then encoded with base64 encoding.
  </xsl:text>
          </xsl:comment>
          <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
            <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
            <xsd:element name="root" msdata:IsDataSet="true">
              <xsd:complexType>
                <xsd:choice maxOccurs="unbounded">
                  <xsd:element name="metadata">
                    <xsd:complexType>
                      <xsd:sequence>
                        <xsd:element name="value" type="xsd:string" minOccurs="0" />
                      </xsd:sequence>
                      <xsd:attribute name="name" use="required" type="xsd:string" />
                      <xsd:attribute name="type" type="xsd:string" />
                      <xsd:attribute name="mimetype" type="xsd:string" />
                      <xsd:attribute ref="xml:space" />
                    </xsd:complexType>
                  </xsd:element>
                  <xsd:element name="assembly">
                    <xsd:complexType>
                      <xsd:attribute name="alias" type="xsd:string" />
                      <xsd:attribute name="name" type="xsd:string" />
                    </xsd:complexType>
                  </xsd:element>
                  <xsd:element name="data">
                    <xsd:complexType>
                      <xsd:sequence>
                        <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                        <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
                      </xsd:sequence>
                      <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
                      <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
                      <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
                      <xsd:attribute ref="xml:space" />
                    </xsd:complexType>
                  </xsd:element>
                  <xsd:element name="resheader">
                    <xsd:complexType>
                      <xsd:sequence>
                        <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
                      </xsd:sequence>
                      <xsd:attribute name="name" type="xsd:string" use="required" />
                    </xsd:complexType>
                  </xsd:element>
                </xsd:choice>
              </xsd:complexType>
            </xsd:element>
          </xsd:schema>
          <resheader name="resmimetype">
            <value>text/microsoft-resx</value>
          </resheader>
          <resheader name="version">
            <value>2.0</value>
          </resheader>
          <resheader name="reader">
            <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
          </resheader>
          <resheader name="writer">
            <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
          </resheader>
          <assembly alias="mscorlib" name="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          <assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
          <data name="TableLayoutPanel.ColumnCount" type="System.Int32, mscorlib">
            <value>2</value>
          </data>
          <data name="TableLayoutPanel.Dock" type="System.Windows.Forms.DockStyle, System.Windows.Forms">
            <value>Fill</value>
          </data>
          <data name="TableLayoutPanel.Location" type="System.Drawing.Point, System.Drawing">
            <value>0, 0</value>
          </data>
          <data name="TableLayoutPanel.RowCount" type="System.Int32, mscorlib">
            <value>
              <xsl:choose>
                <xsl:when test="count($properties)=0">
                  <xsl:text>1</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="count($properties)"/>
                </xsl:otherwise>
              </xsl:choose>
            </value>
          </data>
          <data name="TableLayoutPanel.LayoutSettings" type="System.Windows.Forms.TableLayoutSettings, System.Windows.Forms">
            <value>
              <xsl:text>
              &lt;TableLayoutSettings&gt;
                  &lt;Columns Styles="AutoSize,0,AutoSize,0" /&gt;
                  <!--&lt;Rows Styles="AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,AutoSize,0,Absolute,20" /&gt;-->
              &lt;/TableLayoutSettings&gt;</xsl:text>
              </value>
          </data>
          <data name="&gt;&gt;TableLayoutPanel.Name" xml:space="preserve">
            <value>TableLayoutPanel</value>
          </data>
          <data name="&gt;&gt;TableLayoutPanel.Type" xml:space="preserve">
            <value>System.Windows.Forms.TableLayoutPanel, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
          </data>
          <data name="&gt;&gt;TableLayoutPanel.Parent" xml:space="preserve">
            <value>$this</value>
          </data>
          <data name="&gt;&gt;TableLayoutPanel.ZOrder" xml:space="preserve">
            <value>0</value>
          </data>
          <metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <value>True</value>
          </metadata>
          <data name="$this.AutoScaleDimensions" type="System.Drawing.SizeF, System.Drawing">
            <value>6, 13</value>
          </data>
          <data name="$this.Size" type="System.Drawing.Size, System.Drawing">
            <value>
              <xsl:text>250, </xsl:text><xsl:call-template name="get-hsize" /></value>
          </data>
          <data name="&gt;&gt;$this.Name" xml:space="preserve">
            <value><xsl:value-of select="$domainName"/></value>
          </data>
          <data name="&gt;&gt;$this.Type" xml:space="preserve">
            <value>System.Windows.Forms.UserControl, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
          </data>
          <xsl:apply-templates select="$properties" mode="create-res"/>
        </root>
      </xsl:variable>
      <xsl:value-of select="nyext:generateXmlFile($src, nyext:combinePath($outdir, concat($name, '.resx')))" />
    </xsl:template>

    <!--Template pour créer le fichier de resource-->
  <xsl:template match="property" mode="create-res">
    <xsl:variable name="property_type" select="@type"/>
    <xsl:variable name="enum_type" select="/manifest/types/enum[@name=$property_type]" />
    <xsl:choose>
      <xsl:when test="@type='bool'">
        <xsl:call-template name="res-Label" />
        <xsl:call-template name="res-CheckBox" />
      </xsl:when>
      <xsl:when test="$enum_type">
        <xsl:call-template name="res-Label" />
        <xsl:call-template name="res-ComboBox" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:call-template name="res-Label" />
        <xsl:call-template name="res-TextBox" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!--Label resource-->
  <xsl:template name="res-Label">
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Label.AutoSize')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Boolean, mscorlib</xsl:text>
      </xsl:attribute>
      <value>True</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Label.Margin')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Windows.Forms.Padding, System.Windows.Forms</xsl:text>
      </xsl:attribute>
      <value>3, 5, 3, 0</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Label.Text')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:value-of select="@name"/>
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Label.Name')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:call-template name="get-label" />
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Label.Type')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>System.Windows.Forms.Label, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</xsl:text>
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Label.Parent')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>TableLayoutPanel</xsl:text>
      </value>
    </data>
  </xsl:template>

  <!--CheckBox resource-->
  <xsl:template name="res-CheckBox">
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Editor.AutoSize')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Boolean, mscorlib</xsl:text>
      </xsl:attribute>
      <value>True</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Editor.Size')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Drawing.Size, System.Drawing</xsl:text>
      </xsl:attribute>
      <value>15, 14</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Name')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:call-template name="get-name" />
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Type')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</xsl:text>
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Parent')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>TableLayoutPanel</xsl:text>
      </value>
    </data>
  </xsl:template>

  <!--ComboBox resource-->
  <xsl:template name="res-ComboBox">
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Editor.Margin')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Windows.Forms.Padding, System.Windows.Forms</xsl:text>
      </xsl:attribute>
      <value>3, 3, 30, 3</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Editor.Anchor')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Windows.Forms.AnchorStyles, System.Windows.Forms</xsl:text>
      </xsl:attribute>
      <value>Top, Left, Right</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Name')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:call-template name="get-name" />
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Type')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>System.Windows.Forms.ComboBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</xsl:text>
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Parent')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>TableLayoutPanel</xsl:text>
      </value>
    </data>
  </xsl:template>

  <!--TextBox resource-->
  <xsl:template name="res-TextBox">
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Editor.Margin')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Windows.Forms.Padding, System.Windows.Forms</xsl:text>
      </xsl:attribute>
      <value>3, 3, 30, 3</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat(@name, 'Editor.Anchor')" />
      </xsl:attribute>
      <xsl:attribute name="type">
        <xsl:text>System.Windows.Forms.AnchorStyles, System.Windows.Forms</xsl:text>
      </xsl:attribute>
      <value>Top, Left, Right</value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Name')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:call-template name="get-name" />
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Type')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>System.Windows.Forms.TextBox, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</xsl:text>
      </value>
    </data>
    <data>
      <xsl:attribute name="name">
        <xsl:value-of select="concat('>>', @name, 'Editor.Parent')" />
      </xsl:attribute>
      <xsl:attribute name="xml:space">
        <xsl:text>preserve</xsl:text>
      </xsl:attribute>
      <value>
        <xsl:text>TableLayoutPanel</xsl:text>
      </value>
    </data>
  </xsl:template>

  <xsl:template match="/">
    <xsl:call-template name="generate-user-file" />
    <xsl:call-template name="generate-designer-file" />
    <xsl:call-template name="generate-res-file" />
  </xsl:template>
</xsl:stylesheet>
